import { instance } from "./api.interceptor"
import { IDiscipline } from "../interfaces"

export const DisciplineService = {
    async getAll(): Promise<IDiscipline[]> {
        const resp = await instance.get<IDiscipline[]>('/discipline')
        return resp.data
    },

    async getById(id:number): Promise<IDiscipline> {
        const resp = await instance.get<IDiscipline>(`/discipline/${id}`)
        return resp.data
    },

    async create(dto: { tittle: string, award: number }): Promise<IDiscipline> {
        const resp = await instance.post<IDiscipline>('/discipline', dto)
        return resp.data
    },

    async remove(id:number): Promise<IDiscipline> {
        const resp = await instance.delete<IDiscipline>(`/discipline/${id}`)
        return resp.data
    }

}
